package com.terrapages.wmsc4j;

import java.util.HashMap;
import java.util.Map;

import com.terrapages.wmsc4j.layer.AbstractLayer;

public class WMSC extends HashMap<String, AbstractLayer>
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public AbstractLayer getLayer(String title)
	{
		return get(title);
	}
	
	@Override
	/**
	 * @throws UnsupportedOperationException Please use the add method!!!
	 */
	public AbstractLayer put(String key, AbstractLayer value) {
		throw new UnsupportedOperationException();
	}
	
	@Override
	/**
	 * @throws UnsupportedOperationException Please use the add method!!!
	 */
	public void putAll(Map<? extends String, ? extends AbstractLayer> m) {
		throw new UnsupportedOperationException();
	}
	
	/**
	 * Puts layer into the mapping using the title of the layer as the key of the mapping.
	 * Will not replace the a layer already mapped.
	 * 
	 * @param layer
	 * @return false if the layer title is already mapped to a layer, true if succsesful.
	 */
	public boolean add(AbstractLayer layer) {
		boolean retBool = false;
		if(!containsKey(layer.getTitle()))
		{
			retBool = true;
			put(layer.getTitle(), layer);
		}
		return retBool;
	}
}
